package com.example.activity_02;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends Activity {
    private Button myButton=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        myButton = (Button)findViewById(R.id.myButton);//获取按钮
        myButton.setOnClickListener(new myButtonListener());//让按键按下执行myButtonListener
    }
    class myButtonListener implements View.OnClickListener{

        @Override
        public void onClick(View v) {
            Intent intent =new Intent();
            intent.putExtra("test","123");//用于传递额外数据
            intent.setClass( MainActivity.this,OtherActivity.class );
            //设置从MainActivity跳转到OtherActivity
            MainActivity.this.startActivity(intent);//开始intent

        }
    }
}
